package pchi.pchicamera.functions;

import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;

public class GetCameraID {

	public static int getBackID(Context context) {
		CameraInfo ci = new CameraInfo();
		int result = -1;
		if (HasCamera.checkCameraHardware(context)) {
			for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
				Camera.getCameraInfo(i, ci);
				if (ci.facing == CameraInfo.CAMERA_FACING_BACK) {
					result = i;
				}
			}
		}
		return result;
	}

	public static int getFrontID(Context context) {
		CameraInfo ci = new CameraInfo();
		int result = -1;
		if (HasCamera.checkCameraHardware(context)) {
			if (HasCamera.checkCameraFront()) {
				for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
					Camera.getCameraInfo(i, ci);
					if (ci.facing == CameraInfo.CAMERA_FACING_FRONT) {
						result = i;
					}
				}
			}
		}
		return result;
	}
}
